package com.broadengate.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.orm.hibernate3.support.HibernateDaoSupport;

import com.broadengate.dao.UserDao;
import com.broadengate.model.Card;

/******
 * 提供用户与数据库的交互方法
 * 方法主要有changePassword()实现修改密码；login()实现登陆
 */
public class UserDaoImpl extends HibernateDaoSupport implements UserDao {
	
	@SuppressWarnings("unchecked")
	public void changePassword(Card card) {
		// TODO Auto-generated method stub
		getHibernateTemplate().update(card);
        
	}
	
	@SuppressWarnings("unchecked")
	public List<Card> login(String cardNO, String password) {
		// TODO Auto-generated method stub
		List<Card> list = new ArrayList<Card>();
		list= getHibernateTemplate().find("from Card card where card.cardNo='"+cardNO+"' and card.password='"+password+"'");	
		return null!=list && 0!=list.size() ? list : null;
	}

}
